package top.csmcool.musicapi.util;

/*
 * @description
 * @date 2025/1/27
 * @author shijin
 * @version 1.0
 */

import top.csmcool.musicapi.enums.StatusCode;
import top.csmcool.musicapi.model.result.Result;

public class ResultUtil {

    // 成功响应
    public static <T> Result<T> success(T data) {
        return new Result<T>("00000", "成功", data);
    }

    // 成功响应（无数据）
    public static <T> Result<T> success() {
        return success(null);
    }

    // 失败响应
    public static <T> Result<T> failure(String message) {
        return new Result<T>("9999999", message, null);
    }

    // 失败响应
    public static <T> Result<T> failure(String code,String message) {
        return new Result<T>(code, message, null);
    }

    public static <T> Result<T> failure(StatusCode statusCode) {
        return new Result<T>(statusCode.getCode(), statusCode.getMsg(), null);
    }
}
